package com.example.programming.sendemail;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class EmailController {
    @Autowired
    EmailService emailService;

    @PostMapping("/email")
    public String sendEmail(@RequestParam("emailAddress") String emailAddress) {
        try {
            String code = VerCodeGenerateUtil.generateVerCode();
            EmailService emailService = new EmailService();
            emailService.sendEmailVerCode(emailAddress,code);
            return code;
        } catch (Exception e) {
            return null;
        }
    }
}

